package com.lty.practice.kafka.customer.service.impl;

import com.lty.practice.kafka.customer.integration.Waiter;
import com.lty.practice.kafka.customer.model.Order;
import com.lty.practice.kafka.customer.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private Waiter waiter;

    @Override
    public void newOrder(Order order)  throws Exception{
        log.info("We've send a new order [{}].", order);
        waiter.newOrders().send(MessageBuilder.withPayload(order).build());
    }
}
